/* @flow */
import "./Navigation.css"
import NavigationItem from './NavigationItem.js';
import React from 'react';


export default class Navigation extends React.Component {

    setSelectedItem = (item) => {
        this.props.itemSelected(item);
    };

    render() {

        var items = null;
        if (this.props.items)
        {
            items = this.props.items
                .map((item, index) =>
                    <NavigationItem
                        itemSelected={this.setSelectedItem}
                        selected={item.uri === this.props.currentURI}
                        item={item}
                        key={index}
                    />
                );
        }else {
            items = <div></div>;
        }
        return (
            <div className="navigation">
                <div className="header">Navigations</div>
                <ul>
                    {items}
                </ul>
            </div>
        );
    }
}
